package edu.sctu.yueding.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import edu.sctu.yueding.R;
import edu.sctu.yueding.bean.PointBean;
import edu.sctu.yueding.bean.TaskBean;

/**
 * Created by zcy on 2016/8/24.
 */
public class ScanResultGetTasksAdapter extends BaseAdapter {

    private Activity activity;
    private List<TaskBean> list;

    public ScanResultGetTasksAdapter(Activity activity, List<TaskBean> list) {
        this.activity = activity;
        this.list = list;
    }

    @Override
    public int getCount() {

        if (list != null && list.size() > 0)
            return list.size();

        return 0;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View contentView, ViewGroup viewGroup) {

        View view;

        TextView nameVale, introductionValue,color;
        view = LayoutInflater.from(activity).inflate(R.layout.item_scan_result_get_tasks, null);
        nameVale = (TextView) view.findViewById(R.id.tasks_name_value);
        introductionValue = (TextView) view.findViewById(R.id.tasks_introduction_value);
        color = (TextView) view.findViewById(R.id.color_tv);

        nameVale.setText(list.get(i).getName());

        introductionValue.setText("规则:"+list.get(i).getIntroduction());

        if (i%1 == 0 ){
            color.setBackgroundResource(R.color.upload_news_submit_text);
        }else if(i%2 == 0 ){
            color.setBackgroundResource(R.color.umeng_blue);
        }else if(i%3 == 0 ){
            color.setBackgroundResource(R.color.colorAccent);
        }

        return view;
    }
}
